package com.woniuxy.provider;

import com.woniuxy.entity.Manager;
import com.woniuxy.entity.Order;
import org.apache.ibatis.jdbc.SQL;

public class OrderProvider {

    /**
     * @param order:
     * @return: java.lang.String
     * @description:order根据条件获取的provider
     * @date: 2021/8/12 11:49
     * @author: 魏炳豪
     */
    public String getByCondition(Order order) {
        return new SQL() {{
            SELECT("*");
            FROM("gfr_order");
            if (order != null) {
                if (order.getOrderNum() != null && order.getOrderNum().length() != 0) {
                    WHERE("order_number ='" + order.getOrderNum() + "'");
                }
                if (order.getStatus() != null && order.getStatus().length() != 0) {
                    WHERE("status ='" + order.getStatus() + "'");
                }
                if (order.getUserId() != 0) {
                    WHERE("user_id='" + order.getUserId() + "'");
                }
            }
        }}.toString();
    }
}
